package com.teach.flavour.model.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.teach.util.JsonUtils;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author: Hzz
 * @Date: Created in 23:30 2020/4/28
 */
public class FoodFlavourVector implements Serializable {

    private String foodsId;

    private String foodsName;

    private String url;

    @JsonProperty("salt_rank")
    private int saltRank;
    @JsonProperty("sour_rank")
    private int sourRank;
    @JsonProperty("spicy_rank")
    private int spicyRank;

    private String gropJson;
    
    private int [] vector;

    public int [] getVector(){
        FoodFlavour json = (FoodFlavour) JsonUtils.json("{"+gropJson+"}", FoodFlavour.class);
        if (vector!=null){
            return vector;
        }
        vector=new int[3];
        vector[0]=json.getSalt_rank();
        vector[1]=json.getSour_rank();
        vector[2]=json.getSpicy_rank();
        return vector;
    }
    private void setVector(){
        vector=getVector();
    }

    public String getFoodsName() {
        return foodsName;
    }

    public void setFoodsName(String foodsName) {
        this.foodsName = foodsName;
    }

    public String getFoodsId() {
        return foodsId;
    }

    public void setFoodsId(String foodsId) {
        this.foodsId = foodsId;
    }

    public int getSaltRank() {
        return saltRank;
    }

    public void setSaltRank(int saltRank) {
        this.saltRank = saltRank;
    }

    public int getSourRank() {
        return sourRank;
    }

    public void setSourRank(int sourRank) {
        this.sourRank = sourRank;
    }

    public int getSpicyRank() {
        return spicyRank;
    }

    public void setSpicyRank(int spicyRank) {
        this.spicyRank = spicyRank;
    }

    public String getGropJson() {
        return gropJson;
    }

    public void setGropJson(String gropJson) {
        this.gropJson = gropJson;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public String toString() {
        return Arrays.toString(vector);
    }
}
